from os import name
from matplotlib import pyplot as plt
import numpy as np
import matplotlib.patches as patches
import random
def randomcolor():
    colorArr = ['1','2','3','4','5','6','7','8','9','A','B','C','D','E','F']
    color = ""
    for i in range(6):
        color += colorArr[random.randint(0,14)]
    return "#"+color
 
def drawrect(ax1):
    shu=random.random()
    rect=patches.Rectangle(
        (random.random(),random.random()),   # (x,y)
        shu,          # width
        shu,          # height
        color = randomcolor(),
        alpha=0.5
    )
    ax1.add_patch(rect)

def drawcircle(ax1):
    circ = plt.Circle((random.random(),random.random()), random.random(), color = randomcolor(),alpha=0.5)#圆心，半径，颜色，
    ax1.add_patch(circ)

def drawpoly(ax1):
    x=random.random()
    y=random.random()
    z=random.random()*0.5
    poly=plt.Polygon([[x, y], [x+2*z, y],[x+z, y+z*1.7320]],color = randomcolor(), alpha=0.5) # 0代表全部透明，1不透明
    ax1.add_patch(poly)



def drawapicture(name):
    fig1 = plt.figure(figsize=(2,2))
    ax1 = fig1.add_subplot(111, aspect='equal')
    drawpoly(ax1)
    drawcircle(ax1)
    drawrect(ax1)
    plt.axis('off')
    plt.xticks([])
    plt.yticks([])
    plt.savefig(r'F:\360MoveData\Users\Think\Desktop\keras-yolo3\img1\{}.jpg'.format(name))#保存图片

for i in range(100):
    drawapicture(i)